package nowcoder.day_48.day8;

import java.util.Scanner;

public class Num1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String ss = in.nextLine();
        int n = Integer.parseInt(ss);
        String []words = new String[n];
        for (int i = 0; i < n; i++) {

            words[i] = in.nextLine();
        }
        helper(words);
    }
    public static void helper(String []words){
        if (comLength(words) && !comValue(words)){
            System.out.println("lengths");
            return;
        }
        if (comValue(words) && comLength(words)){
            System.out.println("both");
            return;
        }
        if (!comLength(words)  && !comValue(words)){
            System.out.println("none");
            return;
        }
        if (!comLength(words)&& comValue(words)){
            System.out.println("lexicographically");
            return;
        }

    }
    public static boolean comLength(String []words){
        for (int i = 0; i < words.length - 1; i++) {
            if (words[i].length() > words[i  + 1].length())return false;
        }
        return true;
    }
    public static boolean comValue(String []words){
        for (int i = 0; i < words.length - 1; i++) {
            if (words[i].compareTo(words[i + 1] ) > 0)return false;
        }
        return true;
    }
}
